exports.sendErr = (err, errCode = 500) => {
	return {
		code: errCode,
		msg: err,
	};
};
exports.sendResult = (result, msg = "请求成功") => {
	return {
		code: 0,
		msg: msg,
		data: result,
	};
};
// 处理异步获取不到err问题
exports.asyncHandler = (handler, sucMsg) => {
	return async (req, res, next) => {
		try {
			const result = await handler(req, res, next);
			res.send(exports.sendResult(result, sucMsg));
		} catch (err) {
			next(err);
		}
	};
};
